﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using So_Tu_Phap.module.trang_chu;
using demo2.module.ket_hon;
using demo2.module.xac_nhan_tinh_trang_hon_nhan;
using demo2.module.Khai_tu;
using demo2.module.con_nuoi;
using demo2.module.giam_ho;
using demo2.module.nhan_con;
using demo2.module.QD_cai_chinh;
using So_Tu_Phap.module.PM_khai_sinh;
using Balloon;

namespace So_Tu_Phap
{
    public partial class trangchu : DevComponents.DotNetBar.Metro.MetroForm
    {
        private AlertCustom m_AlertOnLoad = null;
        public trangchu()
        {
            InitializeComponent();
            loaddata();
        }
        private void loaddata()
        {
            css();
            this.WindowState = FormWindowState.Maximized;
            this.timer1.Start();
            this.timer2.Start();
            object makhuvuc = CMSUtils.GetDataSQL("dbo_TB_TaiKhoan", "List_PhuongXa", String.Format("TenTaiKhoan='{0}'", So_Tu_Phap.Properties.Settings.Default.Username), "");
            object tendaydu = CMSUtils.GetDataSQL("dbo_TB_TaiKhoan", "TenDayDu", String.Format("TenTaiKhoan='{0}'", So_Tu_Phap.Properties.Settings.Default.Username), "");
            object tenkhuvuc = CMSUtils.GetDataSQL("dbo_DMKhuVuc", "TenKhuVuc", String.Format("MaKhuVuc='{0}'", makhuvuc), "");
            
            this.MS_Loading.Text = " UBND " + tenkhuvuc.ToString() + " | " + " cán bộ hộ tich :" + tendaydu.ToString().ToUpper();
            //=============  trang chu
            So_Tu_Phap.module.trang_chu.trang_chu trangchu = null;
            trangchu = new So_Tu_Phap.module.trang_chu.trang_chu();
            trangchu.TopLevel = false;
            trangchu.Dock = DockStyle.Fill;
            metroTabPanel1.Controls.Add(trangchu);
            trangchu.Show();
            //=============  tìm kiếm
            So_Tu_Phap.module.tim_kiem.tim_kiem timkiem = null;
            timkiem = new So_Tu_Phap.module.tim_kiem.tim_kiem();
            timkiem.TopLevel = false;
            timkiem.Dock = DockStyle.Fill;
            metroTabPanel10.Controls.Add(timkiem);
            timkiem.Show();
            //============= khai sinh
            khai_sinh khaisinh = null;
            khaisinh = new khai_sinh();
            khaisinh.TopLevel = false;
            khaisinh.Dock = DockStyle.Fill;
            metroTabPanel2.Controls.Add(khaisinh);
            khaisinh.Show();
            //============= kết hôn
            ket_hon Kethon = null;
            Kethon = new ket_hon();
            Kethon.TopLevel = false;
            Kethon.Dock = DockStyle.Fill;
            metroTabPanel3.Controls.Add(Kethon);
            Kethon.Show();
            //============= xác nhận tình trạng
            xac_nhan_tinh_trang_hon_nhan xacnhantinhtrang = null;
            xacnhantinhtrang = new xac_nhan_tinh_trang_hon_nhan();
            xacnhantinhtrang.TopLevel = false;
            xacnhantinhtrang.Dock = DockStyle.Fill;
            metroTabPanel4.Controls.Add(xacnhantinhtrang);
            xacnhantinhtrang.Show();
            //============= khai tử
            khai_tu khaitu = null;
            khaitu = new khai_tu();
            khaitu.TopLevel = false;
            khaitu.Dock = DockStyle.Fill;
            metroTabPanel5.Controls.Add(khaitu);
            khaitu.Show();
            //============= con nuôi
            con_nuoi connuoi = null;
            connuoi = new con_nuoi();
            connuoi.TopLevel = false;
            connuoi.Dock = DockStyle.Fill;
            metroTabPanel6.Controls.Add(connuoi);
            connuoi.Show();
            //============= giám hộ
            giam_ho giamho = null;
            giamho = new giam_ho();
            giamho.TopLevel = false;
            giamho.Dock = DockStyle.Fill;
            metroTabPanel7.Controls.Add(giamho);
            giamho.Show();
            //============= nhận con
            nhan_con nhancon = null;
            nhancon = new nhan_con();
            nhancon.TopLevel = false;
            nhancon.Dock = DockStyle.Fill;
            metroTabPanel8.Controls.Add(nhancon);
            nhancon.Show();
            //============= cai chinh
            qd_cai_chinh caichinh = null;
            caichinh = new qd_cai_chinh();
            caichinh.TopLevel = false;
            caichinh.Dock = DockStyle.Fill;
            metroTabPanel9.Controls.Add(caichinh);
            caichinh.Show();
        }
        #region[UI]
        private void css()
        {
            this.MS_Loading.Size = new System.Drawing.Size(72, 13);
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            this.MS_1.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
        }
        private void trangchu_FormClosing(object sender, FormClosingEventArgs e)
        {
            const string message =
       "Kiểm tra dử liệu trước khi thoát";
            const string caption = "Thoát khỏi chương trình?";
            var result = MessageBoxEx.Show(message, caption,
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

            // If the no button was pressed ... 
            if (result == DialogResult.No)
            {
                // cancel the closure of the form.
                e.Cancel = true;
            }
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            timer2.Stop();
            timer2.Enabled = false;
            ShowLoadAlert();
        }
        private void ShowLoadAlert()
        {
            m_AlertOnLoad = new AlertCustom();
            Rectangle r = Screen.GetWorkingArea(this);
            m_AlertOnLoad.Location = new Point(r.Right - m_AlertOnLoad.Width, r.Bottom - m_AlertOnLoad.Height);
            m_AlertOnLoad.AutoClose = true;
            m_AlertOnLoad.AutoCloseTimeOut = 15;
            m_AlertOnLoad.AlertAnimation = eAlertAnimation.BottomToTop;
            m_AlertOnLoad.AlertAnimationDuration = 300;
            m_AlertOnLoad.Show(false);
        }
        #endregion

    }
}